/**
 * 时间格式过滤器
 * @param val
 * @returns {string}
 */
const formatTime = function (val) {
  if (!val) return '暂无'
  const now = new Date(val)
  const year = now.getFullYear()
  const month = now.getMonth() + 1
  const date = now.getDate() > 9 ? now.getDate() : `0${now.getDate()}`
  const hours = now.getHours() > 9 ? now.getHours() : `0${now.getHours()}`
  const minutes = now.getMinutes() > 9 ? now.getMinutes() : `0${now.getMinutes()}`
  const seconds = now.getSeconds() > 9 ? now.getSeconds() : `0${now.getSeconds()}`
  return `${year}-${month}-${date}, ${hours}:${minutes}:${seconds}`
}
/**
 * 设备信号强度图标显示过滤器
 * */
const getSignalImg = function (value) {
  const { signalIntensity } = value
  let signal = 0
  switch (signalIntensity) {
    case 1:
      signal = 5
      break
    case 2:
      signal = 4
      break
    case 3:
      signal = 3
      break
    case 4:
      signal = 2
      break
    case 5:
      signal = 1
      break
    default:
      signal = 0
      break
  }
  return require(`../../images/signal-${signal}.png`)
}
const Filters = {
  formatTime,
  getSignalImg
}
export default Filters
